#include <ToolCategory>
#include <Tool>

ToolCategory::ToolCategory(const QString &name, const QString &iconPath, QObject *parent) :
    QObject(parent)
  , m_name(name)
{
    loadIcon(iconPath);
}

const QString &ToolCategory::name() const
{
    return m_name;
}

const QIcon &ToolCategory::icon() const
{
    return m_icon;
}

bool ToolCategory::addTool(QPointer<Tool> tool)
{
    if(m_tools.contains(tool)) return false;

    m_tools.append(tool);
    tool->setToolCategory(this);
    return true;
}

const Tools &ToolCategory::tools() const
{
    return m_tools;
}

void ToolCategory::loadIcon(const QString &iconPath)
{
    m_icon = QIcon(iconPath);
    assert(!m_icon.isNull());
}
